﻿<ul class="cloud publication-tag">
@{
    var tmp = (Model as IEnumerable<dynamic>)
        .Where(x => JDM.Int32(x.Weight) != 0);
    if(tmp.Any())
    {
        int minFontSize = 12;
        int maxFontSize = 24;
        int minWeight = tmp.Min(x => (int)JDM.Int32(x.Weight));
        int maxWeight = tmp.Max(x => (int)JDM.Int32(x.Weight));
        maxWeight = Math.Max(minWeight + 1, maxWeight);
        foreach(var i in tmp.Shuffle())
        {
            double weight = JDM.Double(i.Weight) / (maxWeight - minWeight);
            int fontSize = minFontSize + (int)Math.Round((maxFontSize - minFontSize) * weight);
            var t_tag = (i.Translations as IEnumerable<dynamic>)
                .SingleOrDefault(x => JDM.Int32(x.Language.EntityID) ==
                    JDM.Int32(Svc.Localization.Language.EntityID));
            <li><a style="font-size: @(fontSize)px;" href="@Url.Action(Loc.Act("Index").Ctrl("Post").Set(new
            {
                tagID = JDM.Int32(i.EntityID)
            }).Localized())">@String.Format("{0} ({1})", t_tag != null ? JDM.String(t_tag.Name) : JDM.String(i.EntityID), JDM.Int32(i.Weight))</a></li>
        }
    }
    else
    {
        <li class="empty"><span>@T(Res.In("Common").Of("Expr").Name("NoData"))</span></li>
    }
}
</ul>